﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SSS.Core.Model
{
    public class Inventory
    {
        #region 私有成员
        private int inventoryNo; //库存编号
        public int InventoryNo
        {
            get { return inventoryNo; }
            set { inventoryNo = value; }
        }

        private DateTime storageTime; //入库时间
        public System.DateTime StorageTime
        {
            get { return storageTime; }
            set { storageTime = value; }
        }

        private string  storageUserId; //入库负责人id
        public string StorageUserId
        {
            get { return storageUserId; }
            set { storageUserId = value; }
        }

        private DateTime editTime; //最后一次出库时间
        public System.DateTime EditTime
        {
            get { return editTime; }
            set { editTime = value; }
        }

        private string editUserId; //最后一次出库负责人
        public string EditUserId
        {
            get { return editUserId; }
            set { editUserId = value; }
        }

        private DateTime auditTime; //审计时间
        public System.DateTime AuditTime
        {
            get { return auditTime; }
            set { auditTime = value; }
        }

        private string auditUserId; //审计负责人id
        public string AuditUserId
        {
            get { return auditUserId; }
            set { auditUserId = value; }
        }

        private int depotNo; //仓库编号;
        public int DepotNo
        {
            get { return depotNo; }
            set { depotNo = value; }
        }

        private string inventoryId; //货物代号
        public string InventoryId
        {
            get { return inventoryId; }
            set { inventoryId = value; }
        }

        private string inventoryUnit; //商品单位
        public string InventoryUnit
        {
            get { return inventoryUnit; }
            set { inventoryUnit = value; }
        }

        private int inventoryCount;    //库存数量
        public int InventoryCount
        {
            get { return inventoryCount; }
            set { inventoryCount = value; }
        }

        private double purchasePrice; //采购价
        public double PurchasePrice
        {
            get { return purchasePrice; }
            set { purchasePrice = value; }
        }

        private InventoryType type; // 库存类型
        public SSS.Core.Model.InventoryType Type
        {
            get { return type; }
            set { type = value; }
        }
        private string format = "{0}\"inventoryNo\":{1},\"storageTime\":{2},\"storageUserId\":{3},\"editTime\":{4},\"editUserId\":{5},\"auditTime\":{6},\"auditUserId\":{7},\"depotNo\":{8},\"inventoryId\":{9},\"inventoryUnit\":{10},\"inventoryCount\":{11},\"purchasePrice\":{12},\"type\":{13}{14}";
        #endregion

        #region 构造函数
        public Inventory( int inventoryNo, DateTime storageTime, string storageUserId, 
            DateTime editTime, string editUserId, DateTime auditTime,
            string auditUserId, int depotNo, string inventoryId, string inventoryUnit,
            int inventoryCount, double purchasePrice, InventoryType invenTpye )
        {
            this.inventoryNo = inventoryNo;
            this.storageTime = storageTime;
            this.storageUserId = storageUserId;
            this.editTime = editTime;
            this.editUserId = editUserId;
            this.auditTime = auditTime;
            this.auditUserId = auditUserId;
            this.depotNo = depotNo;
            this.inventoryId = inventoryId;
            this.inventoryUnit = inventoryUnit;
            this.inventoryCount = inventoryCount;
            this.purchasePrice = purchasePrice;
            this.type = invenTpye;
        }
        #endregion

        #region 公有成员函数
        public override string ToString()
        {
            return String.Format( format,
                "{",
                inventoryNo == 0 ? "null" : String.Concat("\"",inventoryNo.ToString(),"\""),
                storageTime == DateTime.MinValue? "null" : String.Concat("\"",storageTime.ToString(),"\""),
                storageUserId == null ? "null" : String.Concat("\"",storageUserId,"\""),
                editTime == DateTime.MinValue ? "null" : String.Concat("\"",editTime.ToString(),"\""),
                editUserId == null ? "null" : String.Concat("\"",editUserId,"\""),
                auditTime == DateTime.MinValue ? "null" : String.Concat("\"",auditTime.ToString(),"\""),
                auditUserId == null ? "null" : String.Concat("\"",auditUserId,"\""),
                depotNo == 0 ? "null" : String.Concat("\"",depotNo.ToString(),"\""),
                inventoryId == null ? "null" : String.Concat("\"",inventoryId,"\""),
                inventoryUnit == null ? "null" : String.Concat("\"",inventoryUnit,"\""),
                inventoryCount == 0 ? "0" : String.Concat("\"",inventoryCount.ToString(),"\""),
                purchasePrice == 0.0 ? "0" : String.Concat("\"",purchasePrice.ToString(),"\""),
                type == null ? "null" : type.ToString(),
                "}"
                );
        }

         public InventoryType GetInventoryByJson( string Json )
        {

        }
        #endregion




    }
}
